package com.kgdev.cweb.mbean.store.order;

import java.io.Serializable;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import com.kgdev.cweb.beans.prod.impl.OrderBean;
import com.kgdev.cweb.entities.prod.managed.Order;
import com.kgdev.cweb.mbean.global.session.LoginBean;

@ManagedBean
@ViewScoped
public class OrderView implements Serializable {

	@EJB
	OrderBean orderBean;

	@ManagedProperty(value = "#{loginBean}")
	LoginBean loginBean;

	public void setLoginBean(LoginBean loginBean) {
		this.loginBean = loginBean;
	}

	private Order order;

	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	private static final long serialVersionUID = 1L;

	@PostConstruct
	public void init() {
		initOrder();
	}

	public void initOrder() {
		Integer orderId = (Integer) FacesContext.getCurrentInstance()
				.getExternalContext().getSessionMap()
				.get("orderOrderViewId");
		 order = orderBean.find(orderId);
	}
}
